package com.adou.d9;

import java.net.InetAddress;
import java.net.UnknownHostException;

public class InetAddressTest {
    public static void main(String[] args) throws Exception {
        // 1.获取本机ip对象
        InetAddress ip = InetAddress.getLocalHost();
        System.out.println(ip.getHostName());//djzhou
        System.out.println(ip.getHostAddress());//192.168.243.3

        // 联网
        InetAddress ip2 = InetAddress.getByName("www.baidu.com");
        System.out.println(ip.getHostName());
        System.out.println(ip.getHostAddress());


    }
}
